package Model
{
	import flash.events.EventDispatcher;
	
	import mx.events.PropertyChangeEvent;

	public class ContactInfo
	{
		private var _name:String;
		private var _address:Address;
		private var _modified:Boolean;
		private var _modifiedEvent:PropertyChangeEvent = new PropertyChangeEvent("modified");
		private var _dispatcher:EventDispatcher = new EventDispatcher();
		
		public function ContactInfo()
		{
			this._name = "";
			this._address = new Address();
			this._dispatcher.addEventListener("modified", modifiedHandler);
		}
		
		private function modifiedHandler(event:PropertyChangeEvent):void
		{
			if(this.modified == false)
			{
				this.modified = true;
			}
		}

		public function get modified():Boolean
		{
			return _modified;
		}

		public function set modified(value:Boolean):void
		{
			_modified = value;
		}

		public function get name():String
		{
			return _name;
		}

		public function set name(value:String):void
		{
			_name = value;
			this._dispatcher.dispatchEvent(this._modifiedEvent);
		}

		public function get address():Address
		{
			return _address;
		}

		public function set address(value:Address):void
		{
			_address = value;
			this._dispatcher.dispatchEvent(this._modifiedEvent);
		}

	}
}